/*******************************************************************************
 * Copyright (c) 2012 Clever Devices.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 * 	Clever Devices Interns - 
 * 	Alex Frankel, Andria Young, Kevin Thomas, Nicholas Culpepper, Taner Oztimurlenk, Thomas Volberg
 ******************************************************************************/
package com.framework.rewards;

import java.util.ArrayList;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.framework.cleverstop_tentative.R;
import com.framework.menu.MenuAdapter;
import com.framework.menu.MenuItem;
import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.app.SlidingActivity;

public class WinHistory extends SlidingActivity implements OnItemClickListener {

	TextView display;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rewards_winhistory);
        setSlidingMenu();
        display = (TextView) findViewById(R.id.tvWinHistory);
        
		Drawable d = this.getResources().getDrawable(R.drawable.layout_background);
		getActionBar().setBackgroundDrawable(d);
		getActionBar().setHomeButtonEnabled(true);
    }
    @Override
	public void onItemClick(AdapterView<?> parent, View view, int index, long id) {
		// TODO Auto-generated method stub
		switch (index) {

		// this is where each intent will be started for all of your
		// respective sections. Look to the "BUSTIME" case as a model
		case REWARDS:
			Intent Rewards = new Intent("com.framework.rewards.REWARDS");
			startActivity(Rewards);
			break;
		case BOARDS:
			Intent Customer = new Intent("com.framework.customerservice.CUSTOMER");
			startActivity(Customer);
			break;
		case FARES:
			Intent Fares = new Intent("com.framework.cleverstop_tentative.FARESMAINACTIVITY");
			startActivity(Fares);
			break;
		case BUSTIME:
			Intent BusTime = new Intent(
					"com.framework.cleverstop_tentative.BUSTIMEMAINACTIVITY");
			startActivity(BusTime);
			break;
		}
	}
	
	ListView mainList;
	MenuAdapter listData;
	ListAdapter realListData;
	Button test;

	public final int REWARDS = 0;
	public final int BOARDS = 1;
	public final int FARES = 2;
	public final int BUSTIME = 3;

	/**
	 * Sets up properties for the sliding menu this will keep properties
	 * consistent across all activities
	 */
	public void setSlidingMenu() {
		// sets view that slides out from left, this will be standard across all
		// menus
		// allowing for quick and intuitive navigation
		setBehindContentView(R.layout.persistent_menu_list);
		
		
		MenuItem[] menuItems = {
			new MenuItem("Rewards",R.drawable.rewaredsicon, "1"),
			new MenuItem("Boards",R.drawable.boardsicon, ""),
			new MenuItem("Fares", R.drawable.faresicon, ""),
			new MenuItem("BusTime", R.drawable.bustimeicon, ""),
			new MenuItem("Settings", R.drawable.settinsicon, "")
		};
				
		ArrayList<MenuItem> items = new ArrayList<MenuItem>();
		for(int i = 0; i<menuItems.length;i++)
			items.add(menuItems[i]);
		
		/*
		String[] listItems = { "Rewards", "Boards", "Fares", "BusTime" };
		ArrayList<String> list = new ArrayList<String>();
		list.addAll(Arrays.asList(listItems));
		/*
		listData = new ArrayAdapter<String>(this, R.layout.slider_pullout_row,
				list);
				*/
		listData = new MenuAdapter(this,R.layout.listview_item_row,items);
		
		mainList = (ListView) findViewById(R.id.menuList);

		// dynamically add items to listView
		// did below as a test, but can easily add items based on the section of
		// app you are in
		// listData.insert("BusTime", list.size());

		mainList.setAdapter(listData);
		mainList.setOnItemClickListener(this);

		getSlidingMenu().setBehindOffsetRes(R.dimen.DistanceFromSide);
		getSlidingMenu().setBehindScrollScale(0.5f);
		getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		//getSlidingMenu().setAboveTouchMode(SlidingMenu.TOUCHMODE_MARGIN);
		//getSlidingMenu().setBehindTouchMode(SlidingMenu.TOUCHMODE_FULLSCREEN);
		getSlidingMenu().setActivated(true);

	}
}

